﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using QuizSilverlight.Web;



namespace QuizSilverlight
{
    [Category("Validation")]
    public partial class MainPage : UserControl
    {
        //QuizContext context;
        public MainPage()
        {
            //context = new QuizContext();
            InitializeComponent();
            //  testgrille.ItemsSource = context.Questions;
            //var operation =  context.Load(context.GetQuestionQuery());
            //operation.Completed += new EventHandler(operation_Completed);

        }

        //void operation_Completed(object sender, EventArgs e)
        //{
        //    testgrille.ItemsSource = context.Answers;
        //    context.Load(context.GetAnswerQuery());
        //}


        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by event defined in Xaml.")]

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = new Participant();


        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (validateButton.Content.ToString().Trim() == "Valider Informations".Trim())
            {
                if (participantForm.validationSummary.Errors.Count > 0)
                    MessageBox.Show("Les informations ne sont pas valides");
                else
                {
                    validateButton.Content = "Valider réponse";
                    QuizStoryboard.Begin();
                }
            }

            else MessageBox.Show("Merci pour votre participation");
        }



        /*  private void btValidate_Click(object sender, RoutedEventArgs e)
          {
              if (participantForm.validationSummary.Errors.Count > 0)
                  MessageBox.Show("non valide");
              else
              {
                  MessageBox.Show("Merci Pour Votre Participation");
                  quizForm.Visibility = Visibility.Collapsed;
                  participantForm.Visibility = Visibility.Collapsed;
                  commercials.Visibility = Visibility.Visible;
                  btValidate.Visibility = Visibility.Collapsed;
              }
           
          }*/
    }
}
